package coffee.tigase.client;

import org.jivesoftware.smack.XMPPConnection;
import org.jivesoftware.smack.XMPPException;

/**
 * 
 * @author coffee
 * 
 *         2012-10-30下午2:36:51
 */
public class AccountTest {

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		AccountTest accountTest = new AccountTest();

		accountTest.createUser("2166399", "000000");
	}

	/**
	 * 创建账号
	 * 
	 * @param username
	 *            : 用户名
	 * @param password
	 *            : 密码
	 */
	public void createUser(String username, String password) {
		XMPPConnection conn = XMPPConnectionFactory.create();
		try {
			conn.connect();
			conn.getAccountManager().createAccount(username, password);
			System.out.println("创建账号：" + username + ":" + password);
		} catch (XMPPException e) {
			e.printStackTrace();
		} finally {
			conn.disconnect();
		}
	}

	public void delete(String username, String password) {
		XMPPConnection conn = XMPPConnectionFactory.create();

		try {
			conn.connect();
			conn.login(username, password);
			//
			conn.getAccountManager().deleteAccount();
			System.out.println("删除账号成功");
		} catch (XMPPException e) {
			e.printStackTrace();
		}

		// conn.getAccountManager().deleteAccount();
	}

	// public void getUsers()
	// {
	// XMPPConnection conn = XMPPConnectionFactory.create();
	//
	// User
	// }

}
